# Maintainer: m0rf30 <morf3089@gmail.com>
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/vince_defconfig

pkgname=linux-xiaomi-vince
pkgver=4.9.247
pkgrel=0
pkgdesc="Xiaomi Redmi Note 5 Plus kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="xiaomi-vince"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="sed gcc-armv7 bash bc bison devicepkg-dev flex openssl-dev perl"

# Source
_repository="M0Rf30/kernel_xiaomi_vince"
_commit="3e5718c5b7442064f6755f4b53ff72473ff2b868"
_config="config-$_flavor.$arch"
source="$pkgname-$_commit.tar.gz::https://github.com/$_repository/archive/$_commit.tar.gz
	$_config
	"
builddir="$srcdir/kernel_xiaomi_vince-$_commit"
_outdir="out"

prepare() {
	default_prepare
	REPLACE_GCCH=0 \
		. downstreamkernel_prepare
}

build() {
	unset LDFLAGS
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1))-postmarketOS"
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"
	# Modules
	unset LDFLAGS
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1))-postmarketOS" \
		INSTALL_MOD_PATH="$pkgdir" modules_install
}

sha512sums="ac4dab46b73b781db7fc288174627aeceadf65f047e2071fac6bace7d9de5d227520bceec74a811a9dfcd873999c1f8d1a2dc5a3e1dbc3133e5e55571d935742  linux-xiaomi-vince-3e5718c5b7442064f6755f4b53ff72473ff2b868.tar.gz
5ce1263f527a3d6284a57fb4b21682af251523e8746cac81afecfd5b65b05ddf299adf0c42f5cd10c81072db914e76ebee03ba37fb89b078af6cbb30c727f2d8  config-xiaomi-vince.aarch64"
